package gov.nhso.prov.acc.apps.acc6;

import java.io.OutputStream;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

import com.isud.core.ISUD;
import com.isud.core.ISUDFactory;
import com.isud.paging.PageBean;

import gov.nhso.prov.acc.beans.Acc6VenderBean;
import gov.nhso.prov.acc.core.DBConnection;
import gov.nhso.prov.acc.utils.Utility;

@SuppressWarnings({"rawtypes","deprecation","unchecked"})
public class ACC60107 extends Utility{
	public String url = "/apps/acc6/ACC60107A.jsp";

	public ACC60107(HttpServletRequest request, HttpServletResponse response) {
		this.message(request).clearMsg();
		String job = this.getAttr(request, "job");
		if(job.equals("init")){
			this.clearLastRequest(request, "lastSearch");
			this.init(request);
		}else if(job.equals("add")){
			this.add(request);
		}else if(job.equals("save")){
			this.save(request);
		}else if(job.equals("viewEdit")){
			this.viewEdit(request);
		}else if(job.equals("edit")){
			this.edit(request);
		}else if(job.equals("checkPublicHealth")){
			this.checkPublicHealth(request);
		}else if(job.equals("editVenderType")){
			this.editVenderType(request);
		}else if(job.equals("search")){
			this.setLastRequest(request, "lastSearch");
			this.search(request);
		}else if(job.equals("back")){
			if (this.getLastRequest(request, "lastSearch")) {
				this.search(request);
			} else {
				this.clearLastRequest(request, "lastSearch");
				this.init(request);
			}
		} else if(job.equals("getVenderByProvinceId")){
			this.getVenderByProvinceId(request);
		} else if(job.equals("delete")){
			this.delete(request);
		} else if (job.equals("initUpload")) {
			this.initUpload(request);
		} else if (job.equals("downloadTemplateCheque")) {
			this.downloadTemplate(request, response);
		} else if (job.equals("exportData")) {
			this.exportData(request, response);
		}
		
	}

	private String init(HttpServletRequest request) {
		Connection conn = null;
		ISUD dao = null;
		try {
			conn = DBConnection.getConnection();
			dao = ISUDFactory.create(conn);
			
			request.setAttribute("job", "search");
			this.initPage(request);
			conn.commit();
		} catch (Exception e) {
			try {
				if (conn != null) {
					conn.rollback();
				}
			} catch (SQLException eSQL) {
				eSQL.printStackTrace();
			}
			this.message(request).setMsg("E", e.toString() + ":" + dao.getMessage(), e.getStackTrace());
		} finally {
			try {
				if (conn != null) {
					conn.close();
				}
				dao = null;
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return this.url;
	}
	private String add(HttpServletRequest request){
		Connection conn = null;
		ISUD dao = null;
		try {
			conn = DBConnection.getConnection();
			dao = ISUDFactory.create(conn);
			Acc6VenderBean venderBean = new Acc6VenderBean();
			request.setAttribute("venderBean", venderBean);
			request.setAttribute("job", "save");
			conn.commit();
		} catch (Exception e) {
			try {
				if (conn != null) {
					conn.rollback();
				}
			} catch (SQLException eSQL) {
				eSQL.printStackTrace();
			}
			this.message(request).setMsg("E", e.toString() + ":" + dao.getMessage(), e.getStackTrace());
		} finally {
			try {
				if (conn != null) {
					conn.close();
				}
				dao = null;
				this.url = "/apps/acc6/ACC60107B.jsp";
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return this.url;
	}
	
	private String save(HttpServletRequest request){
		Connection conn = null;
		ISUD dao = null;
		String isContinue = this.getAttr(request, "isContinue");
		try {
			conn = DBConnection.getConnection();
			dao = ISUDFactory.create(conn);
			
			Acc6VenderBean venderBean = new Acc6VenderBean();
			this.beanUtil().copyRequest2Bean(request, venderBean);
			
			venderBean.setVenderCode(this.genCode(dao).getVenderCode(venderBean.getProvinceId()));
			venderBean.setVenderName(venderBean.getVenderName().replaceAll("([\\'\"])", ""));
			venderBean.setVenderAccount(venderBean.getVenderAccount().replace("-", ""));
			venderBean.setVenderAccountNameTh(venderBean.getVenderAccountNameTh().replaceAll("([\\'\"])", ""));
			venderBean.setCreatedBy(this.user(request).getUserId());
			venderBean.setUpdatedBy(this.user(request).getUserId());
			dao.insert(venderBean);
			
			this.message(request).setMsgCode("I002");
			request.setAttribute("provinceId", venderBean.getProvinceId());
			request.setAttribute("isContinue", isContinue);
			request.setAttribute("venderCode", venderBean.getVenderCode());
			conn.commit();
		} catch (Exception e) {
			try {
				if (conn != null) {
					conn.rollback();
				}
			} catch (SQLException eSQL) {
				eSQL.printStackTrace();
			}
			this.message(request).setMsg("E", e.toString() + ":" + dao.getMessage(), e.getStackTrace());
		} finally {
			try {
				if (conn != null) {
					conn.close();
				}
				dao = null;
				if (isContinue.equals("N")) {
					this.viewEdit(request);
				} else {
					request.setAttribute("provinceId", "");
					this.add(request);
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return this.url;
	}

	private String viewEdit(HttpServletRequest request){
		Connection conn = null;
		ISUD dao = null;
		try {
			conn = DBConnection.getConnection();
			dao = ISUDFactory.create(conn);

			Acc6VenderBean venderBean = new Acc6VenderBean();
			String provinceId = this.getAttr(request, "provinceId");
			String venderCode = this.getAttr(request, "venderCode");

			venderBean.setProvinceId(provinceId);
			venderBean.setVenderCode(venderCode);
			dao.select(venderBean);
			
			request.setAttribute("provinceId", provinceId);
			request.setAttribute("provinceName", this.dataUtil(dao).getProvinceName(provinceId));
			request.setAttribute("venderBean", venderBean);
			request.setAttribute("job", "edit");
			
			conn.commit();
		} catch (Exception e) {
			try {
				if (conn != null) {
					conn.rollback();
				}
			} catch (SQLException eSQL) {
				eSQL.printStackTrace();
			}
			this.message(request).setMsg("E", e.toString() + ":" + dao.getMessage(), e.getStackTrace());
		} finally {
			try {
				if (conn != null) {
					conn.close();
				}
				dao = null;
				this.url = "/apps/acc6/ACC60107B.jsp";
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return this.url;
	}
	private String edit(HttpServletRequest request){
		Connection conn = null;
		ISUD dao = null;
		try {
			conn = DBConnection.getConnection();
			dao = ISUDFactory.create(conn);
			String venderType = this.getAttr(request, "venderType");	
			Acc6VenderBean venderBean = new Acc6VenderBean();
			this.beanUtil().copyRequest2Bean(request, venderBean);

			venderBean.setUpdatedBy(this.user(request).getUserId());
			venderBean.setUpdatedDate(this.sysDate);
			venderBean.setVenderName(venderBean.getVenderName().replaceAll("([\\'\"])", ""));
			venderBean.setVenderAccountNameTh(venderBean.getVenderAccountNameTh().replaceAll("([\\'\"])", ""));
			venderBean.setVenderType(venderType);
			dao.update(venderBean);
			
			request.setAttribute("provinceId", venderBean.getProvinceId());
			request.setAttribute("venderCode", venderBean.getVenderCode());
			this.message(request).setMsgCode("I002");
			conn.commit();
		} catch (Exception e) {
			try {
				if (conn != null) {
					conn.rollback();
				}
			} catch (SQLException eSQL) {
				eSQL.printStackTrace();
			}
			this.message(request).setMsg("E", e.toString() + ":" + dao.getMessage(), e.getStackTrace());
		} finally {
			try {
				if (conn != null) {
					conn.close();
				}
				dao = null;
				dao = null;
				this.url = "/apps/acc6/ACC60107B.jsp";
				this.viewEdit(request);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return this.url;
	}
	private String search(HttpServletRequest request){
		Connection conn = null;
		ISUD dao = null;
		try {
			conn = DBConnection.getConnection();
			dao = ISUDFactory.create(conn);
			String condition = "";
			
			Acc6VenderBean venderBean = new Acc6VenderBean();
			PageBean pageBean = new PageBean();
			String provinceId = this.getAttr(request, "provinceId");
			String vanderName = this.getAttr(request, "vanderName");
			String venderCode = this.getAttr(request, "venderCode");
			String venderAccount = this.getAttr(request, "venderAccount");
			String[] vendetType = request.getParameterValues("vendetType");
			//String[] venderExpense = request.getParameterValues("venderExpense");
			String[] strSplit = null;
			venderBean.setProvinceId(provinceId);
			venderBean.setVenderCode(venderCode);
			venderBean.setVenderName(vanderName);
			venderBean.setVenderAccount(venderAccount);
			
			if(vendetType == null){
				condition = "";
			}else{
				condition += "AND (";
				for (int i = 0; i < vendetType.length; i++) {
					strSplit = vendetType[i].split("\\|");
					if(strSplit.length > 0){
						for(int j=0;j<strSplit.length;j++){
							condition += " VENDER_TYPE = '"+strSplit[j]+"' OR";
						}
					}else{
						condition += " VENDER_TYPE = '"+vendetType[i]+"' OR";
					}
					
					if(vendetType[i].equals("M|S")){
						request.setAttribute("vendetTypeM", vendetType[i]);
					}else if(vendetType[i].equals("A")){
						request.setAttribute("vendetTypeA", vendetType[i]);
					}else if(vendetType[i].equals("C|T")){
						request.setAttribute("vendetTypeP", vendetType[i]);
					}
				}
				condition = condition.substring(0, condition.length()-2);
				condition += ")";
			}
			
			if (this.user(request).getAreaLevel().equals("2")){
				condition = " AND PROVINCE_ID IN (SELECT PROVINCE_ID FROM PROVINCE WHERE NHSO_ZONE = '" + this.user(request).getAreaCode()+ "' ) ";
			}
			
			this.beanUtil().copyRequest2Bean(request, pageBean);
			pageBean = dao.selectPage(venderBean, condition, pageBean);
			
			if (pageBean.getPageData() == null) {
				this.message(request).setMsgCode("I001");
			}
			request.setAttribute("pageBean", pageBean);
			request.setAttribute("venderCode", venderCode);
			request.setAttribute("vanderName", vanderName);
			request.setAttribute("venderAccount", venderAccount);
			request.setAttribute("provinceId", provinceId);
			request.setAttribute("job", "search");
			conn.commit();
		} catch (Exception e) {
			try {
				if (conn != null) {
					conn.rollback();
				}
			} catch (SQLException eSQL) {
				eSQL.printStackTrace();
			}
			this.message(request).setMsg("E", e.toString() + ":" + dao.getMessage(), e.getStackTrace());
		} finally {
			try {
				if (conn != null) {
					conn.close();
				}
				dao = null;
				this.url = "/apps/acc6/ACC60107A.jsp";
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return this.url;
	}
	private String checkPublicHealth(HttpServletRequest request){
		Connection conn = null;
		ISUD dao = null;
		try {
			conn = DBConnection.getConnection();
			dao = ISUDFactory.create(conn);
			request.setAttribute("job", "savePublicHealth");
			conn.commit();
		} catch (Exception e) {
			try {
				if (conn != null) {
					conn.rollback();
				}
			} catch (SQLException eSQL) {
				eSQL.printStackTrace();
			}
			this.message(request).setMsg("E", e.toString() + ":" + dao.getMessage(), e.getStackTrace());
		} finally {
			try {
				if (conn != null) {
					conn.close();
				}
				dao = null;
				this.url = "/apps/acc6/ACC60107C.jsp";
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return this.url;
	}

	private String editVenderType(HttpServletRequest request){
		Connection conn = null;
		ISUD dao = null;
		try {
			conn = DBConnection.getConnection();
			dao = ISUDFactory.create(conn);
			
			Acc6VenderBean venderBean = new Acc6VenderBean();
			List listVender = null;
			String[] venderCode = request.getParameterValues("venderCode");
			String[] isCheck = request.getParameterValues("isCheck");
			for(int i =0;i<venderCode.length;i++){
				if(isCheck[i].equals("Y")){
					venderBean.setVenderType("A");
				}else{
					venderBean.setVenderType("M");
				}
				venderBean.setVenderCode(venderCode[i]);
				dao.update(venderBean);
			}
			venderBean = new Acc6VenderBean();
			venderBean.setProvinceId(this.user(request).getAreaCode());
			listVender = dao.selectList(venderBean," AND (VENDER_TYPE='M' OR VENDER_TYPE ='A')");
			if(listVender == null){
				this.message(request).setMsgCode("I001");
			}
			request.setAttribute("listVender", listVender);
			
			this.message(request).setMsgCode("I002");
			conn.commit();
		} catch (Exception e) {
			try {
				if (conn != null) {
					conn.rollback();
				}
			} catch (SQLException eSQL) {
				eSQL.printStackTrace();
			}
			this.message(request).setMsg("E", e.toString() + ":" + dao.getMessage(), e.getStackTrace());
		} finally {
			try {
				if (conn != null) {
					conn.close();
				}
				dao = null;
				this.url = "/apps/acc6/ACC60107C.jsp";
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return this.url;
	}
	private String getVenderByProvinceId(HttpServletRequest request){
		Connection conn = null;
		ISUD dao = null;
		try {
			conn = DBConnection.getConnection();
			dao = ISUDFactory.create(conn);
			Acc6VenderBean venderBean = new Acc6VenderBean();
			List listVender = null;
			
			String provinceId = this.getAttr(request, "provinceId");
			
			venderBean.setProvinceId(provinceId);
			listVender = dao.selectList(venderBean," AND (VENDER_TYPE='M' OR VENDER_TYPE ='A') ORDER BY VENDER_NAME ASC");
			if(listVender == null){
				this.message(request).setMsgCode("I001");
			}
			request.setAttribute("listVender", listVender);
			request.setAttribute("job", "savePublicHealth");
			conn.commit();
		} catch (Exception e) {
			try {
				if (conn != null) {
					conn.rollback();
				}
			} catch (SQLException eSQL) {
				eSQL.printStackTrace();
			}
			this.message(request).setMsg("E", e.toString() + ":" + dao.getMessage(), e.getStackTrace());
		} finally {
			try {
				if (conn != null) {
					conn.close();
				}
				dao = null;
				this.url = "/apps/acc6/ACC60107C.jsp";
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return this.url;
	}
	
	private String delete(HttpServletRequest request){
		Connection conn = null;
		ISUD dao = null;
		try {
			conn = DBConnection.getConnection();
			dao = ISUDFactory.create(conn);
			String provinceId = this.getAttr(request, "provinceId");
			String venderCode = this.getAttr(request, "venderCode");
			Acc6VenderBean avb = new Acc6VenderBean();
			avb.setProvinceId(provinceId);
			avb.setVenderCode(venderCode);
			dao.delete(avb);
			this.message(request).setMsg("I", "บันทึกข้อมูลสำเร็จ");
			conn.commit();
		} catch (Exception e) {
			try {
				if (conn != null) {
					conn.rollback();
				}
			} catch (SQLException eSQL) {
				eSQL.printStackTrace();
			}
			this.message(request).setMsg("E", e.toString() + ":" + dao.getMessage(), e.getStackTrace());
		} finally {
			try {
				if (conn != null) {
					conn.close();
				}
				dao = null;
				request.setAttribute("provinceId", "");
				request.setAttribute("venderCode", "");
				this.search(request);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return this.url;
	}
	
	private String initUpload(HttpServletRequest request) {
		this.url = "/apps/acc6/ACC60107D.jsp";
		return this.url;
	}
	
	private String downloadTemplate(HttpServletRequest request, HttpServletResponse response){
		Connection conn = null;
		ISUD dao = null;
		try {
			conn = DBConnection.getConnection();
			dao = ISUDFactory.create(conn);
			
			response.setContentType("text/vnd.ms-excel");
			response.setHeader("Content-Disposition", "attachment; filename=\"templateVender.xls\"");
			response.setCharacterEncoding("windows-874");
			
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("templateCheque");
			HSSFCellStyle cellStyle = wb.createCellStyle();
			cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
			HSSFRow row = sheet.createRow((short)0);
			
			row.setRowStyle(cellStyle);
			sheet.setDefaultColumnWidth((short) 30);
			row.createCell((short)0).setCellStyle(cellStyle);
			row.createCell((short)1).setCellStyle(cellStyle);
			row.createCell((short)2).setCellStyle(cellStyle);
			row.createCell((short)3).setCellStyle(cellStyle);
			row.createCell((short)4).setCellStyle(cellStyle);
			row.createCell((short)5).setCellStyle(cellStyle);
			row.createCell((short)6).setCellStyle(cellStyle);
			row.createCell((short)7).setCellStyle(cellStyle);

			row.createCell((short)0).setCellValue("รหัสหน่วยบริการ(จากสนย.)/คู่สัญญา");
			row.createCell((short)1).setCellValue("ชื่อหน่วยบริการ/คู่สัญญา");
			row.createCell((short)2).setCellValue("รหัสธนาคาร");
			row.createCell((short)3).setCellValue("ชื่อธนาคาร");
			row.createCell((short)4).setCellValue("รหัสสาขาธนาคาร");
			row.createCell((short)5).setCellValue("ชื่อสาขาธนาคาร");
			row.createCell((short)6).setCellValue("เลขที่บัญชี");
			row.createCell((short)7).setCellValue("ชื่อบัญชี");
			
			row = sheet.createRow((short)1);
			row.createCell((short)0).setCellValue("0000002183");
			row.createCell((short)1).setCellValue("รพ.สต.ตำบลท่าไข่");
			row.createCell((short)2).setCellValue("034");
			row.createCell((short)3).setCellValue("ธกส.");
			row.createCell((short)4).setCellValue("0025");
			row.createCell((short)5).setCellValue("ฉะเชิงเทรา");
			row.createCell((short)6).setCellValue("0252147918");
			row.createCell((short)7).setCellValue("สถานีอนามัยตำบลท่าไข่");
			
			OutputStream out = response.getOutputStream();
			wb.write(out);
			out.close();
			
			conn.commit();
		} catch (Exception e) {
			try {
				if (conn != null) {
					conn.rollback();
				}
			} catch (SQLException eSQL) {
				eSQL.printStackTrace();
			}
			this.message(request).setMsg("E", e.toString() + ":" + dao.getMessage(), e.getStackTrace());
		} finally {
			try {
				if (conn != null) {
					conn.close();
				}
				dao = null;
				this.url = "";
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return this.url;
	}
	
	private String exportData(HttpServletRequest request, HttpServletResponse response){
		Connection conn = null;
		ISUD dao = null;
		try {
			conn = DBConnection.getConnection();
			dao = ISUDFactory.create(conn);
			String provinceId = this.getAttr(request, "provinceId");
			if (provinceId != null && !provinceId.equals("")) {
				String condition = "";
				Map mapBankData = this.getMapBankData();
				Acc6VenderBean venderBean = new Acc6VenderBean();
				String vanderName = this.getAttr(request, "vanderName");
				String venderCode = this.getAttr(request, "venderCode");
				String venderAccount = this.getAttr(request, "venderAccount");
				String venderType = this.getAttr(request,"venderType");
				String[] strSplit = venderType.split(":");
				String[] arrVenderType = null;
				venderBean.setProvinceId(provinceId);
				venderBean.setVenderCode(venderCode);
				venderBean.setVenderName(vanderName);
				venderBean.setVenderAccount(venderAccount);
				
				for (int i = 0; i < strSplit.length; i++) {
					if (strSplit[i] != null && !strSplit[i].equals("")) {
						condition += "AND (";
						arrVenderType = strSplit[i].split("\\|");
						for (int j = 0 ; j < arrVenderType.length ; j++) {
							condition += " VENDER_TYPE = '"+arrVenderType[j]+"' OR";
						}
						condition = condition.substring(0, condition.length()-2);
						condition += ")";
						if(strSplit[i].equals("M|S")){
							request.setAttribute("vendetTypeM", strSplit[i]);
						}else if(strSplit[i].equals("A")){
							request.setAttribute("vendetTypeA", strSplit[i]);
						}else if(strSplit[i].equals("C|T")){
							request.setAttribute("vendetTypeP", strSplit[i]);
						}
					}
					
				}

				if (this.user(request).getAreaLevel().equals("2")){
					condition = " AND PROVINCE_ID IN (SELECT PROVINCE_ID FROM PROVINCE WHERE NHSO_ZONE = '" + this.user(request).getAreaCode()+ "' ) ";
				}
				List lsVender = dao.selectList(venderBean, condition);
				
				response.setContentType("text/vnd.ms-excel");
				response.setHeader("Content-Disposition", "attachment; filename=\"venderData.xls\"");
				response.setCharacterEncoding("windows-874");
				
				HSSFWorkbook wb = new HSSFWorkbook();
				HSSFSheet sheet = wb.createSheet("คู่สัญญาจังหวัด" + this.dataUtil(dao).getProvinceName(provinceId));
				HSSFCellStyle cellStyle = wb.createCellStyle();
				cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
				HSSFRow row = sheet.createRow((short)0);
				
				row.setRowStyle(cellStyle);
				sheet.setDefaultColumnWidth((short) 50);
				row.createCell((short)0).setCellStyle(cellStyle);
				row.createCell((short)1).setCellStyle(cellStyle);
				row.createCell((short)2).setCellStyle(cellStyle);
				row.createCell((short)3).setCellStyle(cellStyle);
				row.createCell((short)4).setCellStyle(cellStyle);
				row.createCell((short)5).setCellStyle(cellStyle);
				row.createCell((short)6).setCellStyle(cellStyle);
				row.createCell((short)7).setCellStyle(cellStyle);

				row.createCell((short)0).setCellValue("รหัสหน่วยบริการ(จากสนย.)/คู่สัญญา");
				row.createCell((short)1).setCellValue("ชื่อหน่วยบริการ/คู่สัญญา");
				row.createCell((short)2).setCellValue("รหัสธนาคาร");
				row.createCell((short)3).setCellValue("ชื่อธนาคาร");
				row.createCell((short)4).setCellValue("รหัสสาขาธนาคาร");
				row.createCell((short)5).setCellValue("ชื่อสาขาธนาคาร");
				row.createCell((short)6).setCellValue("เลขที่บัญชี");
				row.createCell((short)7).setCellValue("ชื่อบัญชี");
					
				for (int i = 0 ; i < lsVender.size() ; i ++ ) {
					row = sheet.createRow((short)(i+1));
					Acc6VenderBean bean = (Acc6VenderBean) lsVender.get(i);
					row.createCell((short)0).setCellValue(bean.getVenderCode());
					row.createCell((short)1).setCellValue(bean.getVenderName());
					row.createCell((short)2).setCellValue(bean.getVenderBankCode());
					row.createCell((short)3).setCellValue(dao.chkData(mapBankData.get(bean.getVenderBankCode())));
					row.createCell((short)4).setCellValue(bean.getVenderBankBranchCode());
					row.createCell((short)5).setCellValue(bean.getVenderBankBranchName());
					row.createCell((short)6).setCellValue(bean.getVenderAccount());
					row.createCell((short)7).setCellValue(bean.getVenderAccountNameTh());
				}
				
				OutputStream out = response.getOutputStream();
				wb.write(out);
				out.close();
				this.message(request).clearMsg();
				this.url = "";
			} else {
				this.message(request).setMsg("W", "กรุณาเลือกจังหวัด");
				this.url = "/apps/acc6/ACC60107A.jsp";
			}
			
			conn.commit();
		} catch (Exception e) {
			try {
				if (conn != null) {
					conn.rollback();
				}
			} catch (SQLException eSQL) {
				eSQL.printStackTrace();
			}
			this.message(request).setMsg("E", e.toString() + ":" + dao.getMessage(), e.getStackTrace());
		} finally {
			try {
				if (conn != null) {
					conn.close();
				}
				dao = null;
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return this.url;
	}
	private Map getMapBankData(){
		Map mapBankData = new HashMap();
		mapBankData.put("034","BAAC : ธนาคารเพื่อการเกษตรและสหกรณ์การเกษตร");
		mapBankData.put("002","BBL : ธนาคารกรุงเทพ");
		mapBankData.put("004","KBANK : ธนาคารกสิกรไทย");
		mapBankData.put("006","KTB : ธนาคารกรุงไทย");
		mapBankData.put("011","TMB : ธนาคารทหารไทย");
		mapBankData.put("014","SCB : ธนาคารไทยพาณิชย์");
		mapBankData.put("020","SCBT : ธนาคารสแตนดาร์ดชาร์เตอร์ด");
		mapBankData.put("022","CIMB : ธนาคารซีไอเอ็มบี ไทย");
		mapBankData.put("024","UOB : ธนาคารยูโอบี");
		mapBankData.put("025","AYUD : ธนาคารกรุงศรีอยุธยา");
		mapBankData.put("030","GSBA : ธนาคารออมสิน");
		mapBankData.put("033","GHB : ธนาคารอาคารสงเคราะห์");
		mapBankData.put("035","EXTH : ธนาคารเพื่อการส่งออกและนำเข้าแห่งประเทศไทย");
		mapBankData.put("065","TBNK : ธนาคารธนชาติ");
		mapBankData.put("066","TIBT : ธนาคารอิสลามแห่งประเทศไทย");
		mapBankData.put("067","TISCO : ธนาคารทิสโก้");
		mapBankData.put("069","KK : ธนาคารเกียรตินาคิน");
		mapBankData.put("073","LHB : ธนาคารแลนด์ แอนด์ เฮ้าส์");
		return mapBankData;
	}
}
